using Assets.Scripts.GDK;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class MusicBox : gdk_base_UI
	{
		public Sprite[] sprites;

		public Image musicBtn;

		public float soundVolume;

		public override void OnLoad()
		{
			init();
		}

		private void init()
		{
			soundVolume = gdk_music.Instance.GetSoundVolume();
			if (soundVolume == 1f)
			{
				musicBtn.sprite = sprites[1];
			}
			else
			{
				musicBtn.sprite = sprites[0];
			}
		}

		public void OnMusicClick()
		{
			gdk_game_manager.PlaySound(AudioID.click);
			if (soundVolume == 1f)
			{
				soundVolume = 0f;
			}
			else
			{
				soundVolume = 1f;
			}
			if (soundVolume == 1f)
			{
				musicBtn.sprite = sprites[1];
			}
			else
			{
				musicBtn.sprite = sprites[0];
			}
			gdk_music.Instance.ChangeSoundVolume(soundVolume);
		}
	}
}

